package com.xz.usercenter.model.enums;

import lombok.Getter;
import lombok.Setter;

import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;

/**
 * @author xuzhou
 * @description 队伍状态枚举
 */
@Getter
public enum TeamStatusEnum {
    PUBLIC(0, "公开"),
    PRIVATE(1, "私有"),
    SECRET(2, "加密");

    @Setter
    private int value;

    @Setter
    private String text;

    public static TeamStatusEnum getEnumByValue(Integer value) {
        if (value == null) {
            return null;
        }
        TeamStatusEnum[] values = TeamStatusEnum.values();
        for (TeamStatusEnum teamStatusEnum : values) {
            if (teamStatusEnum.getValue() == value) {
                return teamStatusEnum;
            }
        }
        return null;
    }

    TeamStatusEnum(int value, String text) {
        this.value = value;
        this.text = text;
    }

    /**
     * 获取枚举值列表
     * 通过map操作提取每个枚举项的value字段，
     * 最后通过collect方法收集这些值到一个List<Integer>中通过map操作提取每个枚举项的value字段，
     *
     * @return
     */
    public static Collection<Integer> getValues() {
        return Arrays.stream(TeamStatusEnum.values())
                .map(TeamStatusEnum::getValue)
                .collect(Collectors.toList());
    }
}
